class Solution(object):
    def mySqrt(self, x):
        """
        :type x: int
        :rtype: int
        """
        guess = x/2.0
        bias = 0.0000000001
        # while abs(guess**2-x)>bias:
        for _ in range(20):
            if abs(guess**2-x)>bias:
                guess = (guess+x/guess)/2.0
            else:
                break
        return int(guess+bias)

print(Solution().mySqrt(2))
